<?php

namespace App\Http\Requests\Logic\Consociation;

use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class StoreResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
        	'partner' => 'required|integer',
            'type' => [
                'required',
                Rule::in(array_keys(config('system.consociation.type')))
            ],
        	'project_id' => 'required|integer',
        	'buttman' => 'required',
        	'contact' => 'required|integer',
        	'start' => 'required|date',
            'deadline' => 'required|date',
        	'permissions' => 'required|array',
            'status' => 'nullable',
            'comment' => 'nullable',
        ];
    }

	/**
	 * 定义表单验证错误消息
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'partner.required' => '请选择公司名称',
            'partner.integer' => '请选择正确公司信息',
            'type.required' => '请输入合作类型',
            'type.in' => '合作类型不存在',
			'project_id.required' => '请选择项目名称',
            'project_id.integer' => '请选择正确项目名称',
			'buttman.required' => '请输入负责人',
			'contact.required' => '请输入负责人联系方式',
            'contact.integer' => '请输入正确的联系方式',
            'start.required' => '请输入开始日期',
            'start.date' => '请输入正确的开始日期',
            'deadline.required' => '请输入截止日期',
            'deadline.date' => '请输入正确的截止日期',
            'permissions.required' => '请分配权限',
            'permissions.array' => '请分配正确权限',
        ];
    }
}
